-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: embed durableObjects exports into workers script #10117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The last comment on the linked issue is from this time last year - is there not a better solution than having to edit an adapter at buildtime? Also is it a build or dev issue this is solving? |
@ghostdevv I am trying to solve a build issue, but it would work for both build and dev. There has to be an export for Durable Object class in the worker file - and I do not see how I can achieve this otherwise. I'd be happy if someone would confirm that's the best way to do it as of now. |
The PR doesn't seem to work for me currently but I think it's because you aren't doing anything with the read file. However IMO we should probably take advantage of esbuild by copying the durable objects file to Something like // Copy durable objects
if (options.durableObjects) {
builder.copy(options.durableObjects, `${tmp}/durableObjects.ts`)
} else {
builder.copy(`${files}/durableObjects.js`, `${tmp}/durableObjects.ts`)
builder.copy('./src/durableObjects.ts', `${tmp}/durableObjects.ts`)
builder.copy('./src/durableObjects.js', `${tmp}/durableObjects.js`)
} wdyt? |
Oh wow oops, I incorrectly copied my solution into PR. I have now amended the commit, please check it out! |
@ghostdevv did you have a chance to check out the update? |
I am still not sure the best way to copy everything across, so trying to get a second opinion there.Regardless we'd still need to support TypeScript ootb, and I think we should set the default file to Another thing that just occurred to me is that when we document this, we need to note that sk specific imports like |
feature: simple embedding of file that exports Durable Objects classes
#1712
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.